//
// Created by Administrator on 2023/11/13.
//
#include "iostream"

using namespace std;

int n, q;
int *A = new int[n];
int *qs = new int[q];
int *from = new int[q];
int *to = new int[q];


void binary_search(int low, int high, int i) {
    if (low > high) return;

    int mid = (low + high) / 2;

    if (A[mid] == qs[i]) {
        if (from[i] == -1 && to[i] == -1) {
            from[i] = mid;
            to[i] = mid;
            binary_search(mid + 1, high, i);
            binary_search(low, mid - 1, i);
        }
        else if (from[i] > mid) from[i] = mid;
        else if (to[i] < mid)to[i] = mid;
    }

    else if(A[mid] > qs[i])binary_search(low,mid-1,i);

    else binary_search(mid+1,high,i);
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> A[i];
    for (int i = 0; i < q; ++i) {
        cin >> qs[i];
        from[i] = -1;
        to[i] = -1;
    }
    for (int i = 0; i < q; ++i)
        binary_search(0, n - 1, i);


    for (int i = 0; i < q; ++i)
        cout << from[i] << ' ' << to[i] << endl;

}